import requests

def GraphTool():
    url = "http://8.152.2.23:8214/message"
    params = {
        'id': 1
    }
    try:
        response = requests.get(url, params=params)
        # 检查请求是否成功
        response.raise_for_status()  # 如果状态码不是200，将抛出HTTPError异常
        # 假设API返回的是JSON格式的数据
        data = response.json()
        response.close()
        # 打印返回的JSON数据
        return data
    except requests.RequestException as e:
        # 处理任何请求异常
        print(f"Error occurred: {e}")




def SubmitItem(item):
    #将识别完的文字提交至服务器
    url = "http://8.152.2.23:8214/message"
    param = {
        'key': 'FerpaApi',
        'item': item
    }
    # 发送GET请求
    response = requests.get(url, params=param)
    if response.status_code == 200:
        response_data = response.json()
        return response_data
    else:
        errorCode = response.status_code
        errorText = response.text
        return errorCode, errorText


